package dialog;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.taobao.ibatiside.ui.util.JavaClassDialog;
import org.taobao.ibatiside.ui.util.SqlmapFileDialog;

public class DialogMain {

	protected Shell shell;
	private Text txtA;
	private Text txtB;

	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			DialogMain window = new DialogMain();
			window.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shell = new Shell();
		shell.setSize(450, 300);
		shell.setText("SWT Application");
		
		txtA = new Text(shell, SWT.BORDER);
		txtA.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseDoubleClick(MouseEvent e) {
				JavaClassDialog jcd = new JavaClassDialog(shell, null);
				jcd.open();
			}
		});
		txtA.setText("class");
		txtA.setBounds(10, 10, 73, 23);
		
		txtB = new Text(shell, SWT.BORDER);
		txtB.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseDoubleClick(MouseEvent e) {
				SqlmapFileDialog dialog = new SqlmapFileDialog(shell, null);
				dialog.open();
			}
		});
		txtB.setText("sqlmapfile");
		txtB.setBounds(96, 10, 73, 23);

	}

}
